﻿using Reticulum.MasterForm;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Reticulum
{
    public partial class Master : Form
    {
        public Master()
        {
            InitializeComponent();
        }

        private void Master_Load(object sender, EventArgs e)
        {
            //panel4.Height = 500;
            //panel4.Width = 800;
        }

        private void Navigationbar_Paint(object sender, PaintEventArgs e)
        {

        }

        //用户管理
        public static Insert insert = new Insert();//增加的窗体
        public static Delete delete = new Delete();//删除的窗体
        public static Updata Updata = new Updata();//修改的窗体
        public static new Select Select = new Select();//查询的窗体
        public static jurisdiction jurisdiction = new jurisdiction();//权限管理窗体
        public static SealForm SealForm  = new SealForm();//封禁窗体

        //文件管理
        public static new FlieSelect flieSelect = new FlieSelect();//查询的窗体

        private void UserAdd_Click(object sender, EventArgs e)
        {
            

        }

        private void Masterover_MouseDown(object sender, MouseEventArgs e)
        {
            Application.Exit();   
        }

        private void Mastermini_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void DelUser_Click(object sender, EventArgs e)
        {
            

        }

        private void Masterover_Click(object sender, EventArgs e)
        {

        }

        private void ModifyUser_Click(object sender, EventArgs e)
        {
            

        }

        private void SelectUser_Click(object sender, EventArgs e)
        {
            
        }
        //无边框拖动窗体-----------------------------------------------------------------------------------
        [DllImport("user32.dll")]//*********************拖动无窗体的控件  需要引用
        public static extern bool ReleaseCapture();
        [DllImport("user32.dll")]
        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
        public const int W = 0x0112;
        public const int S = 0xF010;
        public const int H = 0x0002;
        private void Navigationbar_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(this.Handle, W, S + H, 0);//*********************调用移动无窗体控件函数
        }
        //无边框拖动窗体-----------------------------------------------------------------------------------

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void UserManagement_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)//返回登陆界面
        {
            Hide();
            LoginHome loginHome = new LoginHome();
            loginHome.ShowDialog();
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            delete.TopLevel = false;
            panel4.Controls.Add(delete);
            delete.Show();
        }

        //一个按钮触发两个事件
        public static bool mastergo = true;
        public static bool mastergo2 = true;
        public static bool mastergo3 = true;



        private void button1_Click(object sender, EventArgs e)
        {
            if (mastergo)
            {
                button2.Visible = true;
                button6.Visible = true;
                button7.Visible = true;
                button8.Visible = true;
            }
            else
            {
                button2.Visible = false;
                button6.Visible = false;
                button7.Visible = false;
                button8.Visible = false;
            }
            mastergo = !mastergo;
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            insert.TopLevel = false;
            panel4.Controls.Add(insert);
            insert.Show();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            
        }

        private void button5_Click(object sender, EventArgs e)
        {
           
        }

        private void button6_Click(object sender, EventArgs e)
        {
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            delete.TopLevel = false;
            panel4.Controls.Add(delete);
            delete.Show();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            Updata.TopLevel = false;
            panel4.Controls.Add(Updata);
            Updata.Show();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            Select.TopLevel = false;
            panel4.Controls.Add(Select);
            Select.Show();
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            if (mastergo2)
            {
                button4.Visible = true;
                button5.Visible = true;
            }
            else
            {
                button4.Visible = false;
                button5.Visible = false;
            }
            mastergo2 = !mastergo2;
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (mastergo3)
            {
                button10.Visible = true;
                button11.Visible = true;
            }
            else
            {
                button10.Visible = false;
                button11.Visible = false;
            }
            mastergo3 = !mastergo3;
        }

        private void button5_Click_1(object sender, EventArgs e)
        {
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            flieSelect.TopLevel = false;

            panel4.Controls.Add(flieSelect);
            flieSelect.Show();
        }

        private void button4_Click_1(object sender, EventArgs e)
        {
            AllFlie allFlie = new AllFlie();
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            allFlie.TopLevel = false;
            panel4.Controls.Add(allFlie);
            allFlie.Show();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            //jurisdiction jurisdiction = new jurisdiction();
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            jurisdiction.TopLevel = false;
            panel4.Controls.Add(jurisdiction);
            jurisdiction.Show();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            panel4.Controls.Clear();//清除容器
            //设置子窗体在容器里的方法
            SealForm.TopLevel = false;
            panel4.Controls.Add(SealForm);
            SealForm.Show();
        }
    }
}

